import React from 'react'
import '../css/InputBox.css'
import {PENDDING,} from './config.js'

class InputBox extends React.Component {
    constructor(props){
        super(props)
    }


    render() {
     return (
         <div className="InputBox_con">
             <div className="InputBox_con_text">
                 <span className="con_style">
                     ToDoList
                 </span>
                <input className="con_type" onKeyDown={(event)=>{
                    //获取key值
                    var keyCode = event.keyCode
                    // console.log(keyCode);
                    var value = this.refs.input.value

                    if(keyCode == 13){
                        if(value.length === 0){
                            alert("内容不能为空")
                            return
                        }

                        var todo = {
                            content:value,
                            status:PENDDING
                        }
                        this.props.addTodo(todo)
                    }
                }} ref="input"/>
             </div>
             <div>

             </div>
         </div>
     )   
    }
}

export default InputBox